package com.codemeta.bokit.social.config;

import com.codemeta.bokit.props.SocialProps;
import com.xkcoding.http.HttpUtil;
import com.xkcoding.http.support.hutool.HutoolImpl;
import com.xkcoding.justauth.autoconfigure.CacheProperties.CacheType;
import com.xkcoding.justauth.autoconfigure.JustAuthProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * 社交组件自动装配
 *
 * @author hice
 */
@Slf4j
@Configuration
@AutoConfigureAfter(JustAuthProperties.class)
@EnableConfigurationProperties(SocialProps.class)
public class JustAuthAutoConfig {

    @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
    public JustAuthAutoConfig(JustAuthProperties props) {
        props.getCache().setType(CacheType.REDIS);
        log.debug("【bokit】修改社交组件默认缓存实现为Redis");
        HttpUtil.setHttp(new HutoolImpl());
        log.debug("【bokit】指定社交组件默认使用hutool-http实现");
    }

}